// 负责系统用户的仓库
const state = {
  UserList: [], // 管理员列表
  loading: false,
  pager: {
    currentPage: 1, // 当前页码
    pageSize: 10, // 每一页的数量
    currentStatus: '5', // 默认显示所有数据
    prevStatus: 5, // 上一次加载过的数据
    total: 0 // 总记录数
  },
  statusPanel: [ // 用户列表标签页数据
    {
      name: "所有账户",
      status: "5"
    },
    {
      name: "待激活",
      status: "0"
    },
    {
      name: "正常",
      status: "1"
    },
    {
      name: "已锁定",
      status: "2"
    },
    {
      name: "已停用",
      status: "3"
    },
    {
      name: "已注销",
      status: "4"
    }
  ],
  searchUserList: [], // 存储搜索用户列表
  currentUserData: [], // 存储更新当前账号的数据
  currentRoleData: [] // 存储更新当前账号的数据
}

const getters = {
  getUserList (state) {
    return state.UserList
  },
  getLoading (state) {
    return state.loading
  },
  getPager (state) {
    return state.pager
  },
  getStatusPanel (state) {
    return state.statusPanel
  },
  getSearchUser (state) {
    return state.searchUserList
  },
  getCurrentUser (state) {
    return state.currentUserData
  },
  getCurrentRole (state) {
    return state.currentRoleData
  }
}

const mutations = {
  setUserList (state, payload) {
    state.UserList = payload
  },
  setLoading (state, payload) {
    state.loading = payload
  },
  setPager (state, payload) {
    Object.keys(payload).forEach((key) => {
      state.pager[key] = payload[key]
    })
  },
  setSearchUser (state, payload) {
    state.searchUserList = payload
  },
  setCurrentUser (state, payload) {
    state.currentUserData = payload
  },
  setCurrentRole (state, payload) {
    state.currentRoleData = payload
  }
}

export default {
  namespaced: true,
  state,
  getters,
  mutations
  // actions
}
